from dataclasses import dataclass, field


@dataclass(order=True)
class Student:
    sort_index: int = field(init=False, repr=False)

    name: str
    age: int

    def __post_init__(self):
        self.sort_index = self.age


s_1 = Student("tony", 18)
s_2 = Student("jack", 19)

students = [s_1, s_2]
students.sort()
print(students)

